<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">
        
        <h3>Advertisement Manager</h3>
        <br/>
        <br/>
        <h5>Create Advertisement</h5>
        <h:form id="upload">
            <h:panelGrid   columns="3" style="text-align: left">
                
                <h:outputLabel for="title" value="Advertisement Title: "/>
                <p:inputText id="title" value="#{advertisementMB.title}" required="true"
                             requiredMessage="Ads Title required!"/>
                <br/>

                <h:outputLabel for="URL" value="URL: "/>
                <p:inputText id="URL" value="#{advertisementMB.link}" required="true"
                             requiredMessage="Ads URL required!"/>
                <br/>

                <h:outputLabel for="effectiveStart" value="Effective Start Date: "/>
                <p:calendar id="effectiveStart" value="#{advertisementMB.startDate}"
                            pattern="dd MMM, yyyy (EEE)" required="true" requiredMessage="Start Date is required"/>
                <br/>


                <h:outputLabel for="effectiveEnd" value="Effective End Date: "/>
                <p:calendar id="effectiveEnd" value="#{advertisementMB.endDate}"
                            pattern="dd MMM, yyyy (EEE)" required="true" requiredMessage="End Date is required"/>
                <br/>

                <h:outputLabel for="Keywords" value="Keywords: "/>
                <p:inputText id="Keywords" value="#{advertisementMB.tags}" required="true"
                             requiredMessage="Keywords required!"/>
                <br/>
                <h:outputLabel for="Price" value="Place Impression Bidding Price: "/>
                <p:inputText id="Price" value="#{advertisementMB.biddingPrice}" required="true"
                             requiredMessage="BiddingPrice required!"/>
                <br/>
                <h:outputLabel for="MaxClick" value="Daily Click Budget: "/>
                <p:inputText id="MaxClick" value="#{advertisementMB.maxClicks}" required="true"
                             requiredMessage="Daily Click Budget required!"/>
                <br/>
                <h:outputLabel for="MaxImp" value="Daily Impression Budget: "/>
                <p:inputText id="MaxImp" value="#{advertisementMB.maxImpression}" required="true"
                             requiredMessage="Daily Impression Budget required!"/>
                <br/>
                <h:outputText value="Charge by amount of Clicks: "/>
                <h:selectBooleanCheckbox value="#{advertisementMB.isClick}"/><br/>
                <br/>
                <h:outputText value="Charge by amount of Impression: "/>
                <h:selectBooleanCheckbox value="#{advertisementMB.isImpression}"/><br/>
                <br/>
                <h:outputText value="Upload Image: "/>
                <h:form enctype="multipart/form-data" prependId="false">
                    <p:growl id="growl2" showDetail="true" life="2000"></p:growl> 
                    <p:fileUpload fileUploadListener="#{photoManagedBean.handleAdvertisementPhotoUpload}" multiple="false" label="Browse" auto="true" allowTypes="*.jpg;*.png;*.gif;" description="Images" update="upload:pic" />
                </h:form><br/>
                <h:outputLabel for="pic" value="Preview Image: "/> 
                <p:graphicImage id="pic" value="#{photoManagedBean.photoFilePath}" height="100"
                                width="100"/><br/><br/>

                <h:outputLabel for="description" value="Description: "/> 
                <p:inputTextarea id="description" 
                                 value="#{advertisementMB.description}" 
                                 required="true" requiredMessage="Description needed!"
                                 style="width:500px; height:200px"/>


            </h:panelGrid>

            <p:commandButton id="newAdvertisement" value="Submit new Ads" ajax="false"
                             actionListener="#{advertisementMB.addNewAdvertisement}"
                             update="display" />


        </h:form>
        
        
        

    </ui:define>

</ui:composition>